package com.multithreading.algorithm;

/**
 * @author zx
 * @version 1.0
 * @package_name: com.multithreading.algorithm
 * @date 2024/6/19 15:32
 */
public class Array_test001 {

    public static void main(String[] args) {

        int[] arr = new int[10];

        // 随机生成10个数字
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (int) (Math.random() * (99 - 10 + 1)) + 10;
            System.out.print(arr[i] + " ");
        }
        // 求最大值
        int max = 10;
        for (int i = 1; i < arr.length; i++) {
            if (max < arr[i]) {
                max = arr[i];
            }
        }
        System.out.println("最大值为：" + max);
        // 求最小值
        int min = 100;
        for (int i = 1; i < arr.length; i++) {
            if (min > arr[i]) {
                min = arr[i];
            }
        }
        System.out.println("最小值为：" + min);
        // 求和
        int sum = 0;
        for (int i = 1; i < arr.length; i++) {
            sum += arr[i];
        }
        System.out.println("和为：" + sum);
        // 求平均值
        double avg = (double) sum / arr.length;
        System.out.println("平均值为：" + avg);
    }
}
